import sqlite3

def insert(list:list) -> None:
    sql = "insert into user_teacher(username,password,truename,role,phone,email,activate)values(?,?,?,?,?,?,?)"
    conn = sqlite3.connect("class_manager.db")
    cursor = conn.cursor()
    cursor.executemany(sql, list)
    conn.commit()
    cursor.close()
    conn.close()
def listAll(activate):
    sql = "select username,phone,truename,email from user_teacher where activate = ?"
    conn = sqlite3.connect("class_manager.db")
    cursor = conn.cursor()
    cursor.execute(sql, [activate])
    list = cursor.fetchall()
    cursor.close()
    conn.close()
    return list
def search(truename):
    sql = "select username,phone,truename,email from user_teacher where truename = ?"
    conn = sqlite3.connect("class_manager.db")
    cursor = conn.cursor()
    cursor.execute(sql, (truename,))
    list = cursor.fetchall()
    cursor.close()
    conn.close()
    return list
def accept(username):
    sql = "update user_teacher set activate = 1 where username = ?"
    conn = sqlite3.connect("class_manager.db")
    cursor = conn.cursor()
    cursor.execute(sql, (username,))
    conn.commit()
    cursor.close()
    conn.close()
def reject(username):
    sql = "delete from user_teacher where username = ?"
    conn = sqlite3.connect("class_manager.db")
    cursor = conn.cursor()
    cursor.execute(sql, (username,))
    conn.commit()
    cursor.close()
    conn.close()
